import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false
// 引入css
import "@/assets/style.css"
// 引入axios
import axios from "@/utils/request"
Vue.prototype.axios=axios

// 设置全局自定义指令
Vue.directive("lazy",{
  inserted(el,binding){
    const observer=new IntersectionObserver(([{isIntersecting}])=>{
      if(isIntersecting){
        observer.unobserve(el)
        el.src=binding.value
        // 图片加载失败 钩子函数 onerror js自带的
        el.onerror=()=>{
          // el.src=errorimg
        }
      }
    })
    observer.observe(el)
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
